import AdSearch from '@/components/AdSearch';
// import { queryPerson } from '@/utils/common';
import AdSelect from '@/components/AdSelect';

export const codes = {
  add: 'add',
  edit: 'edit',
  save: 'save',
  search: 'search',
  import: 'import',
  delete: 'delete',
  detail: 'detail',
};

export const formate = 'YYYY-MM-DD';
export const formateTime = 'YYYY-MM-DD HH:mm';
// 包装单位
export const packageUnitList = [{ code: 'PALLET', value: '托盘' }, { code: 'CTNS', value: '箱' }];
// 噸車/貨櫃尺寸
export const containerSizeList = [
  { code: '5T', value: '5T' },
  { code: '8T', value: '8T' },
  { code: '10T', value: '10T' },
  { code: '12T', value: '12T' },
  { code: "40'", value: "40'" },
];
//状态
export const statusList = [
  { code: '1', value: '已受理' },
  { code: '2', value: '待受理' },
  { code: '3', value: '已驳回' },
  { code: '4', value: '已取消' },
];
//轨迹状态
export const statusTrailList = [
  { code: 'SUBMIT', value: '已提交' },
  { code: 'PROCESS', value: '进行中' },
  { code: 'FINISHED', value: '已完成' },
  { code: 'EXCEPTION', value: '异常' },
  { code: 'NOT', value: '查询不到' },
  { code: '', value: '异常' },
];
/*贸易条款：*/
export const incotermList = [
  { code: 'C&F', value: 'C&F' },
  { code: 'CFR', value: 'CFR' },
  { code: 'CIF', value: 'CIF' },
  { code: 'CIP', value: 'CIP' },
  { code: 'DAP', value: 'DAP' },
  { code: 'DAT', value: 'DAT' },
  { code: 'DDP', value: 'DDP' },
  { code: 'DDU', value: 'DDU' },
  { code: 'EXW', value: 'EXW' },
  { code: 'FCA', value: 'FCA' },
  { code: 'FOB', value: 'FOB' },
  { code: 'HKN', value: 'HKN' },
  { code: 'NUOO', value: 'NUOO' },
  { code: 'T/T', value: 'T/T' },
  { code: '第三方付款', value: '第三方付款' },
  { code: '其它', value: '其它' },
];

export const allDispatchType = {
  list: 'exportOS/selectExportOSList',
  detail: 'exportOS/selectExportOSDetail',
  operate: 'exportOS/operateExportOS',
  value: 'exportOS/allValus',
  partsDetail: 'exportOS/selectPapersDetail',
  setTabsName: 'common/setTabsName',
  queryExportOSDict: 'component/queryExportOSDict',
  delete: 'exportOS/delExportOS',
  cancelOrder: 'exportOS/cancelOrder',
  operateFile: 'exportOS/operateOrderFile',
  getOrderFile: 'exportOS/getOrderFile',
  genBills: 'exportOS/generatedBills',
  getOrderNo: 'exportOS/getAutoOrderNo',
  getAddress: 'exportOS/getAreaByAddress',
  //地址
  contactList: 'exportOS/contactList',
  operateAddress: 'exportOS/operateAddress',
  delContact: 'exportOS/delContact',
  discernAddress: 'exportOS/discernAddress',
  //车型列表
  getTruckTypeList: 'exportOS/getTruckTypeList',
};

export const routeUrl = {
  add: '/portal/myOrder/exportOSList/addExportOS',
  edit: '/portal/myOrder/exportOSList/editExportOS',
  trail: '/portal/myOrder/trailList',
};

export const allUrl = {
  // userList: 'tms/tms-papers/selectUserList_s',
  // companyList: 'mds/d-customer/selectCompany',
  customerList: 'api/User/User/GetCustomerList',
  // driverDetail: 'tms/tms-driver/viewDetails',
};

export function saveAllValues({ payload = {}, props } = {}) {
  const { dispatch } = props;
  dispatch({
    type: allDispatchType.value,
    payload,
  });
}

export function selectExportOSList({ payload = {}, props } = {}) {
  const { dispatch, searchValue } = props;
  dispatch({
    type: allDispatchType.list,
    payload,
    callback: data => {
      if (!data) return;
      // queryPerson({ data, props, url: allUrl.userList });
    },
  });
}

export function selectPaperDetail({ type, payload, props, callback }) {
  const { dispatch } = props;
  dispatch({
    type,
    payload,
    callback: data => {
      if (!data) return;
      callback && callback(data);
    },
  });
}

export function renderTableAdSelect({ key, data, value, props }) {
  let params = { onlyRead: true, value };
  if (key) {
    const { dictObject } = props;
    params = { data: dictObject[key], payload: { code: [key] }, ...params };
  } else {
    params = { data, ...params };
  }
  return <AdSelect {...params} />;
}

export function renderTableAdSearch({ value, props }) {
  const { searchValue } = props;
  if (!value || !searchValue) return '';
  const params = {
    onlyRead: true,
    value: searchValue[value],
    label: 'loginName',
    name: 'sysName',
  };
  return <AdSearch {...params} />;
}

//测试数据：
export const truckDataTest = {
  code: 0,
  message: '请求(或处理)成功',
  data: {
    list: [
      {
        vipOrderNo: '',
        queryNo: '',
        querySource: 'HIC',
        orderNo: '5226907634',
        orderSource: 'OCS',
        customerOrderNo: '',
        bizStatus: 'SUBMIT',
        bizCode1: '',
        bizCode2: '',
        customerCode: '204570',
        customerName: 'Lenovo (Hong Kong) Limited',
        orderTime: '2019-09-13 07:59:44',
        fromLocation: '',
        toLocation: '',
        estimatedArrivalTime: '',
        productType: '',
        productName: '',
        taskPlan: '',
        orderLine: '',
        consignor: '',
        consignee: '',
        orderTracking: [
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-18 16:47',
            eventDesc: '签收',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-18 16:47',
            eventDesc: '香港出仓',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-17 09:37',
            eventDesc: '香港入仓',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-16 20:03',
            eventDesc: '深圳出仓',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-15 10:08',
            eventDesc: '深圳入仓',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
          {
            position: '',
            positionLatitude: '',
            positionLongitude: '',
            nextPostion: '',
            nextPositionLatitude: '',
            nextPositionLongitude: '',
            eventCode: 'OTHER',
            eventTime: '2019-09-12 18:37',
            eventDesc: '工厂发货时间',
            eventSource: 'OCS',
            operator: 'SCCTadmin',
            fileUrl: '',
            trackFiles: [],
            sourceCode: '',
            sourceCarNumber: '',
            handoverPerson: '',
            beShow: '',
            remarks: '',
          },
        ],
      },
    ],
  },
};
